<?php
$pid = pcntl_fork();
if ($pid==0){
    fprintf(STDOUT,"我是子进程pid=%d,运行后我就没事了.\n",posix_getpid());
    exit;
}else{
    fprintf(STDOUT,"我是父进程pid=%d\n",posix_getpid());
    $exitPid = pcntl_wait($status);
    if ($exitPid>0){
        fprintf(STDOUT,"pid=%d，子进程已经挂了，它的终止状态码:%d,并且已经完全释放了它所占用的资源...\n",$pid,$status);
    }else{
        fprintf(STDOUT,"wait error...\n");
    }
    while (1){
        fprintf(STDOUT,"我在打印...\n");
        sleep(3);
    }
}
fprintf(STDOUT,"pid=%d结束\n",getmypid());